//
//  TeacherCell.m
//  SDSY
//
//  Created by 蓝布鲁 on 2017/3/22.
//  Copyright © 2017年 蓝布鲁. All rights reserved.
//

#import "TeacherCell.h"
#import "TeacherModel.h"

@interface TeacherCell ()
@property (nonatomic,retain)UIImageView *headerImageView;
@property (nonatomic,retain)UILabel *teacherNameLabel;
@property (nonatomic,retain)UILabel *orderNumberLabel;

@end

@implementation TeacherCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupView];
    }
    return self;
}

-(void)setupView {
    // 导师头像
    self.headerImageView = [[UIImageView alloc] init];
    self.headerImageView.layer.masksToBounds = true;
    self.headerImageView.layer.cornerRadius = 25;
    [self.contentView addSubview:self.headerImageView];
    
    // 导师名
    self.teacherNameLabel = [[UILabel alloc] init];
    self.teacherNameLabel.font = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:self.teacherNameLabel];
    
    // 导师预约次数
    self.orderNumberLabel = [[UILabel alloc] init];
    self.orderNumberLabel.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.orderNumberLabel];
    
    // 布局视图
    self.headerImageView.sd_layout.topSpaceToView(self.contentView,10).leftSpaceToView(self.contentView,10).heightIs(50).widthIs(50);
    self.teacherNameLabel.sd_layout.topEqualToView(self.headerImageView).leftSpaceToView(self.headerImageView,5).rightSpaceToView(self.contentView,10).heightIs(18);
    self.orderNumberLabel.sd_layout.leftEqualToView(self.teacherNameLabel).bottomEqualToView(self.headerImageView).rightEqualToView(self.teacherNameLabel).heightIs(15);
    
    [self setupAutoHeightWithBottomView:self.headerImageView bottomMargin:10];
}

- (void)setModel:(TeacherModel *)model {
    _model = model;
    // 导师头像
    [self.headerImageView sd_setImageWithURL:[NSURL URLWithString:self.model.img_url] placeholderImage:[UIImage imageNamed:@"avatar_default"]];

    // 导师名
    self.teacherNameLabel.text = self.model.name;

    // 导师预约次数
    self.orderNumberLabel.text = [NSString stringWithFormat:@"热度值:%d",self.model.frequency];
}


@end
